package com.example.friend.controller;


import com.example.core.domain.PageDomain;
import com.example.core.domain.R;
import com.example.core.domain.TableDataInfo;
import com.example.friend.domain.vo.UserMessageVO;
import com.example.friend.service.IUserMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/message")
@Tag(name = "用户消息API")
public class UserMessageController {

    @Autowired
    private IUserMessageService userMessageService;

    @Operation(summary = "消息列表")
    @GetMapping("/list")
    public TableDataInfo list(PageDomain page) {
        return userMessageService.selectUserMessageList(page);
    }

    @Operation(summary = "消息详情")
    @GetMapping("/detail")
    public R<UserMessageVO> detail(Long messageId, Long textId) {
        return R.ok(userMessageService.detail(messageId, textId));
    }

    @Operation(summary = "消息删除")
    @DeleteMapping("/delete")
    public R<?> delete(Long messageId) {
        return R.ok(userMessageService.delete(messageId));
    }
}
